﻿#include "OperNCTMultiple.h"
#include "FITK_Kernel/FITKAppFramework/FITKAppFramework.h"
#include "FITK_Kernel/FITKAppFramework/FITKGlobalData.h"
#include "GUIDialog/GUIPhyscisDialog/NCTDialogMultiple.h"
#include "FITK_Component/FITKAcousticsPhysics/FITKAcousticsPhysics.h"
#include "FITK_Component/FITKAcousticsPhysics/FITKAcousticsAbsNCT.h"

#include "updateBrowserTable.h"
namespace ModelOper
{
    bool OperNCTMultiple::execGUI()
    {
        //按钮点击事件触发
        if (_emitter == nullptr) return false;
        const QString name = _emitter->objectName();
        if (name == "actionMultipleNoiseControlTreatment")
            createNCT();
        return false;
    }
    bool OperNCTMultiple::execProfession()
    {
        return false;
    }
    void OperNCTMultiple::createNCT()
    {
        //弹出对话框
        QWidget* mw = FITKAPP->getGlobalData()->getMainWindow();
        GUI::NCTDialogMultiple dlg(GUI::PhysicsDlgExecType::Create, -1, mw);
        //更新列表
        if (QDialog::Accepted == dlg.exec())
            ModelOper::updateBrowserTable();
    }
    void OperNCTMultiple::duplicateNCT(const int nctID)
    {
        QWidget* mw = FITKAPP->getGlobalData()->getMainWindow();
        //编辑对话框
        GUI::NCTDialogMultiple dlg(GUI::PhysicsDlgExecType::Duplicate, nctID, mw);
        //更新列表
        if (QDialog::Accepted == dlg.exec())
            ModelOper::updateBrowserTable();
    }
    void OperNCTMultiple::editNCT(const int nctID)
    {
        QWidget* mw = FITKAPP->getGlobalData()->getMainWindow();
        //编辑对话框
        GUI::NCTDialogMultiple dlg(GUI::PhysicsDlgExecType::Edit, nctID, mw);
        //更新列表
        if (QDialog::Accepted == dlg.exec())
            ModelOper::updateBrowserTable();
    }
    void OperNCTMultiple::removeNCT(const int nctID)
    {
        //获取管理器
        Acoustics::FITKAcousticsPhysics* phys = Acoustics::FITKAcousticsPhysics::GetAcousticsPhysicsFromFrame();
        if (phys == nullptr) return;
        Acoustics::FITKAcousticsNCTManager* nctMgr = phys->getFITKAcousticsNCTManager();
        if (nctMgr == nullptr) return;
        //移除并更新列表
        nctMgr->removeDataByID(nctID);
        ModelOper::updateBrowserTable();
    }

}